package com.augurit.common.calendar.web.form;

import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;

import com.augurit.common.base.form.BaseForm;
import com.augurit.common.util.lang.DateUtils;
import com.augurit.common.workdayholiday.model.Time;

public class SysCalendarForm extends BaseForm{
	// 属性
	private Long eventId;
	private Long eventTypeId;
	private String title;
	private Date startDate;
	private Date endDate;
	private String isAllDay;
	private String isNew;
	private String url;
	private String location;
	private String content;
	private Long reminder;
	
	private String startTime;
	private String endTime;
	
	private Long creatorId;
	private Long ownerId;
	private String isPublic;
	
	private String creatorName;
	private String ownerName;
	private boolean canEdit;
	private Long[] sharedUserIds;		//共享用户id列表
	private String[] shareTypes;		//共享类型列表

	public Long getEventId() {
		return this.eventId;
	}

	public void setEventId(Long eventId) {
		this.eventId = eventId;
	}
	
	public Long getEventTypeId() {
		return eventTypeId;
	}

	public void setEventTypeId(Long eventTypeId) {
		this.eventTypeId = eventTypeId;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getIsAllDay() {
		return this.isAllDay;
	}

	public void setIsAllDay(String isAllDay) {
		this.isAllDay = isAllDay;
	}
	public String getIsNew() {
		return this.isNew;
	}

	public void setIsNew(String isNew) {
		this.isNew = isNew;
	}
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	public String getLocation() {
		return this.location;
	}

	public void setLocation(String location) {
		this.location = location;
	}
	
	
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Long getReminder() {
		return this.reminder;
	}

	public void setReminder(Long reminder) {
		this.reminder = reminder;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}
	
	/**
	 * 重新设置事件开始日期、时间
	 * @throws Exception
	 */
	public void reSetStartDate()throws ParseException{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(startDate);		
		//获取小时、分钟
		int startHour = Time.detachHours(startTime);
		int startMinute = Time.detachMinutes(startTime);
		//重新设置小时分钟
		calendar.set(Calendar.HOUR_OF_DAY, startHour);
		calendar.set(Calendar.MINUTE, startMinute);
		this.setStartDate(calendar.getTime());
	}
	
	/**
	 * 重新设置事件结束日期、时间
	 * @throws Exception
	 */
	public void reSetEndDate() throws ParseException{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(endDate);
		//获取小时、分钟
		int endHour = Time.detachHours(endTime);
		int endtMinute = Time.detachMinutes(endTime);
		//重新设置小时分钟
		calendar.set(Calendar.HOUR_OF_DAY, endHour);
		calendar.set(Calendar.MINUTE, endtMinute);
		this.setEndDate(calendar.getTime());
	}
	
	/**
	 * 重新设置时间起始时刻
	 */
	public void reSetStartTime(){
		this.setStartTime(DateUtils.dateTimeToString(startDate, "HH:mm"));
	}
	
	/**
	 * 重新设置时间结束时刻
	 */
	public void reSetEndTime(){
		this.setEndTime(DateUtils.dateTimeToString(endDate, "HH:mm"));
	}


	public Long getCreatorId() {
		return creatorId;
	}

	public void setCreatorId(Long creatorId) {
		this.creatorId = creatorId;
	}

	public Long getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(Long ownerId) {
		this.ownerId = ownerId;
	}

	public String getIsPublic() {
		return isPublic;
	}

	public String setIsPublic() {
		return isPublic;
	}

	public void setIsPublic(String isPublic) {
		this.isPublic = isPublic;
	}

	public Long[] getSharedUserIds() {
		return sharedUserIds;
	}

	public void setSharedUserIds(Long[] sharedUserIds) {
		this.sharedUserIds = sharedUserIds;
	}

	public String[] getShareTypes() {
		return shareTypes;
	}

	public void setShareTypes(String[] shareTypes) {
		this.shareTypes = shareTypes;
	}

	public String getOwnerName() {
		return ownerName;
	}

	public void setOwnerName(String ownerName) {
		this.ownerName = ownerName;
	}

	public String getCreatorName() {
		return creatorName;
	}

	public void setCreatorName(String creatorName) {
		this.creatorName = creatorName;
	}

	public boolean isCanEdit() {
		return canEdit;
	}

	public void setCanEdit(boolean canEdit) {
		this.canEdit = canEdit;
	}
	
	@Override
	public boolean equals(Object other){
		if(this == other)
			return true;
		
		SysCalendarForm form = (SysCalendarForm)other;
		return form.eventId.longValue() == this.eventId.longValue();
	}
	
	@Override
	public int hashCode(){
		return this.eventId.hashCode();
	}
}
